#include <stdio.h>
#include <stdlib.h>
int GetGCD(int, int);
int main( void )
{
    int iVal1, iVal2; 
    int result; 
    scanf("%d%d", &iVal1, &iVal2);
    result = GetGCD(iVal1, iVal2);
    printf("%d\n", result);
    return 0;
}
int GetGCD(int m, int n)
{
    int r; 
    if(m < n)
    {
        m ^= n;
        n ^= m;
        m ^= n;
    }
    while(n != 0)
    {
        r = m % n;
        m = n;
        n = r;
    }

    return m;
}

